package lab03.test07;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Test07 {
    public static void main(String[] args) {
        String path="D:\\java实验\\book.rar";
        ZipInputStream zipInputStream=null;
        BufferedReader bufferedReader=null;
        BufferedWriter bufferedWriter=null;

        try{
            zipInputStream=new ZipInputStream(new FileInputStream(path));

            byte[] bytes=new byte[1024];

            ZipEntry entry;

            while ((entry=zipInputStream.getNextEntry())!=null){
                File file=new File("D:\\"+entry.getName());
                System.out.println(file);
                if (!file.exists()){
                    file.mkdirs();
                    file.createNewFile();
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                zipInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
